/*
 * TreeFactory.java
 *
 * Created on February 20, 2007, 9:01 PM
 * Makes <code>Tree</code>s out of (1) a <code>Symbol</code> and (2)
 * a linked list of other <code>Tree</code>s.  Makes decisions as to whether
 * the result should be a <code>UnaryTree</code>, <code>BinaryTree</code>
 * or <code>NaryTree</code>
 */

package galronnlp.util;
import java.util.LinkedList;

/**
 *
 * @author Dennis N. Mehay
 */
public class TreeFactory {
    
    public static Tree makeTree(Symbol s, LinkedList<Tree> children) {
        if(children.size()==1) {
            return new UnaryTree(s, children.getFirst());
        } else if(children.size()==2) {
            return new BinaryTree(s, children.getFirst(), children.get(1));
        } else { return new NaryTree(s, children); }
    }
    
    public static Tree makeTree(Symbol s, Tree child) {
        return new UnaryTree(s, child);
    }
}
